import React, { useState, useEffect } from 'react';

export default function() {
  const [ count, setCount ] = useState(0);
  // 一种是不需要手动清理（cleanup）的
  useEffect(() => {
    document.title = `You clicked ${count} times`;
    return () => {
      console.log('unbind ');
    }
  }, []);
  return (
    <div>
      <p>点击了{count}次</p>
      <button onClick={() => setCount(count+1)}>
        Click
      </button>
    </div>
  )
}
